package com.donghu.study;

import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import java.io.IOException;

@WebServlet(urlPatterns = "/XyY/add")
public class UserAdd extends HttpServlet {
    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
        resp.setContentType("text/html;charset=utf-8");
        // 获取请求中键名为 name 的值
        String name = req.getParameter("name");
        // 获取请求中键名为 username 的值
        String username= req.getParameter("username");


        String sql = "INSERT INTO user(`username`,`password`,`name`) VALUES(?,MD5('666666'),?);";
        JdbcUtils.modify(sql, username, name);
        resp.sendRedirect("user-list.jsp");
    }
}
